project(QUtauStd)

set(QUTAUSTD_NAME QUtauStd)
set(QUTAUSTD_VERSION 0.0.1)
set(QUTAUSTD_FILENAME QUtauStd)
set(QUTAUSTD_DIR ${CMAKE_CURRENT_SOURCE_DIR})

set(QT_LIBS)
set(QUTAUSTD_FILES)
set(RES_FILES)

# 查找Qt库
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
list(APPEND QT_LIBS Qt${QT_VERSION_MAJOR}::Core)

# 添加源文件
if (WIN32)
    list(APPEND RES_FILES ${QUTAUSTD_DIR}/win32/res.rc)
endif()

file(GLOB QUTAUSTD_FILES ${QUTAUSTD_DIR}/*.h ${QUTAUSTD_DIR}/*.cpp)

# 构建库
if(BUILD_STATIC_LIBRARY)
    add_library(${QUTAUSTD_NAME} STATIC ${QUTAUSTD_FILES} ${RES_FILES})
    target_compile_definitions(${QUTAUSTD_NAME} PUBLIC QUTAUSTD_BUILD_STATIC)
else()
    add_library(${QUTAUSTD_NAME} SHARED ${QUTAUSTD_FILES} ${RES_FILES})
endif()
target_compile_definitions(${QUTAUSTD_NAME} PRIVATE QUTAUSTD_LIBRARY)

set_target_properties(${QUAZIP_LIB_TARGET_NAME} PROPERTIES
    VERSION ${QUTAUSTD_VERSION}
    OUTPUT_NAME ${QUTAUSTD_FILENAME}
)

target_link_libraries(${QUTAUSTD_NAME} PUBLIC ${QT_LIBS})
target_include_directories(${QUTAUSTD_NAME} PUBLIC ${QUTAUSTD_DIR})
